@echo off

set path=%path%;c:\Program Files\Microsoft Visual Studio 8\Common7\IDE

rem Clean everything first
devenv iegdinfo.sln /project hal /projectconfig "Release|Win32" /clean
devenv iegdinfo.sln /project iegdsample /projectconfig "Release|Win32" /clean
devenv iegdinfo.sln /project hal_dll /projectconfig "Release|Win32" /clean
if exist Release\iegdinfo_static.lib del Release\iegdinfo_static.lib

devenv iegdinfo.sln /project hal /projectconfig "Debug|Win32" /clean
devenv iegdinfo.sln /project iegdsample /projectconfig "Debug|Win32" /clean
devenv iegdinfo.sln /project hal_dll /projectconfig "Debug|Win32" /clean
if exist Debug\iegdinfo_static.lib del Debug\iegdinfo_static.lib


if "%1" == "" goto BUILD_RELEASE
if "%1" == "release" goto BUILD_RELEASE
if "%1" == "debug" goto BUILD_DEBUG


:BUILD_RELEASE
echo IEGDUI build 

rem Now start building in the order that we want
devenv iegdinfo.sln /project hal /projectconfig "Release|Win32" /rebuild
if exist hal\src\Release\iegdui.lib copy /y hal\src\Release\iegdui.lib Release\iegdui_static.lib
devenv iegdinfo.sln /project hal /projectconfig "Release|Win32" /clean
devenv iegdinfo.sln /project hal_dll /projectconfig "Release|Win32" /rebuild
devenv iegdinfo.sln /project iegdsample /projectconfig "Release|Win32" /rebuild


goto END

:BUILD_DEBUG
echo IEGDUI build 

rem Now start building in the order that we want
devenv iegdinfo.sln /project hal /projectconfig "Debug|Win32" /rebuild
if exist hal\src\Debug\iegdui.lib copy /y hal\src\Debug\iegdui.lib Debug\iegdui_static.lib
devenv iegdinfo.sln /project hal /projectconfig "Debug|Win32" /clean
devenv iegdinfo.sln /project hal_dll /projectconfig "Debug|Win32" /rebuild
devenv iegdinfo.sln /project iegdsample /projectconfig "Debug|Win32" /rebuild


goto END

:END
echo DONE